﻿using System.Windows;
using VolunteerManager.ViewModel;

namespace VolunteerManager
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        /// <summary>
        /// Initializes a new instance of the MainWindow class.
        /// </summary>
        public MainWindow()
        {
            InitializeComponent();
            Closing += (s, e) =>
            {
                ViewModelLocator.Cleanup();
                App.Current.Shutdown();

            };
        }

        private void MenuImportItem_Click(object sender, RoutedEventArgs e)
        {
            new WinImport().ShowDialog();
        }

        private void MenuChangPass_Click(object sender, RoutedEventArgs e)
        {
            new WinChangePassword().ShowDialog();
        }

        private void DataGrid_LoadingRow(object sender, System.Windows.Controls.DataGridRowEventArgs e)
        {
            e.Row.Header = e.Row.GetIndex() + 1;
        }

        private void DataGrid_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            if (e.OriginalSource is System.Windows.Controls.ScrollViewer)
            {
            }
            else
            {
                (this.DataContext as MainViewModel).EditCommand.Execute(null);
            }
        }
    }
}